﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

using WindowsFormsApplication1;

namespace SvD_Templates
{
    class Template
    {
        // Regular Template
        private string validateUserProfile = "Verified user's profile: Yes";
        private string verifiedAsset = "Verified asset: ";
        private string userCompany = "What company do you work for? ";
        private string language = "Language: ";
        private string verifiedSecurity = "Verified SSN/RFC/EN: ";
        private string issue = "Issue: ";
        private string isThisAnIMAC = "Is this an IMAC? ";
        private string keyword = "Keyword: ";
        private string troubleshooting = "Troubleshooting: ";
        private string dispatching = "Are you dispatching, where? ";
        private string timeToReachUser = "At what time can user be reached? ";
        private string warmTransfer = "Did you WT, who answered? ";
        private string severity = "Severity (choose area of impact and answer those questions): ";
        private string alternateContact = "User’s alternate number or alternate contact information: ";
        private string whatPartOfBusiness = "What part of the business is this outage impacting? ";
        
        //Severity Questions
        private string SQ_Shipments_1 = "Customer Impacted ? ";
        private string SQ_Shipments_2 = "Due Date and Time ? ";
        private string SQ_Shipments_3 = "Is there a Workaround ? ";

        private string SQ_Manufacturing_1 = "Customer Impacted ? ";
        private string SQ_Manufacturing_2 = "Impact will be in HH:MM? ";
        private string SQ_Manufacturing_3 = "Is there a Workaround ? ";

        private string SQ_Business_1 = "What part of the Business is impacted ? ";
        private string SQ_Business_2 = "Due Date and Time ? ";
        private string SQ_Business_3 = "Is there a Workaround ? ";

        private string SQ_Outage_1 = "What type of outage ? ";
        private string SQ_Outage_2 = "Number of user’s impacted ? ";
        private string SQ_Outage_3 = "Is there a Workaround ? ";

        private string SQ_Other_1 = "10+ users impacted ? ";
        private string SQ_Other_2 = "Single user SAP High Priority issue ? ";
        private string SQ_Other_3 = "Critical VIP incident ? ";

        // Template Footer
        private string ticketProvided = "Ticket provided: ";
        private string url = "URL: ";

        public void CrearTemplate(datosTemplate datos)
        {
            string templateClip = "";
            string enter = Environment.NewLine + Environment.NewLine;
            string singleEnter = Environment.NewLine;
            string tab = "     ";

            templateClip += datos.Titulo + enter;
            templateClip += validateUserProfile + enter;
            templateClip += verifiedAsset + datos.Verificar_Asset + enter;
            templateClip += userCompany + datos.user_Company + enter;
            templateClip += language + datos.Idioma + enter;
            templateClip += verifiedSecurity + datos.Verificar_SSNRFC + enter;
            templateClip += issue + datos.Detalles_Ticket + enter;

            templateClip += isThisAnIMAC + datos.Es_IMAC + enter;
            templateClip += keyword + datos.Keyword + enter;
            templateClip += troubleshooting + datos.Acciones_Realizadas + enter;
            templateClip += dispatching + datos.Caja_Asignacion + enter;
            templateClip += timeToReachUser + datos.Mejor_Hora_Localizar + enter;
            templateClip += warmTransfer + datos.Warm_Transfer + enter;
            templateClip += severity + datos.Severidad + enter;
            templateClip += alternateContact + datos.Contact_Alterno + enter;

            //Severity Questions
            templateClip += whatPartOfBusiness + enter;
            templateClip += tab + "SHIPMENTS" + singleEnter;
            templateClip += tab + SQ_Shipments_1 + datos.SQ_Shipments_1 + singleEnter;
            templateClip += tab + SQ_Shipments_2 + datos.SQ_Shipments_2 + singleEnter;
            templateClip += tab + SQ_Shipments_3 + datos.SQ_Shipments_3 + enter;
            templateClip += tab + "MANUFACTURING (Production)" + singleEnter;
            templateClip += tab + SQ_Manufacturing_1 + datos.SQ_Manufacturing_1 + singleEnter;
            templateClip += tab + SQ_Manufacturing_2 + datos.SQ_Manufacturing_2 + singleEnter;
            templateClip += tab + SQ_Manufacturing_3 + datos.SQ_Manufacturing_3 + enter;
            templateClip += tab + "BUSINESS (Finance, HR, Medical, Exchange, etc)" + singleEnter;
            templateClip += tab + SQ_Business_1 + datos.SQ_Business_1 + singleEnter;
            templateClip += tab + SQ_Business_2 + datos.SQ_Business_2 + singleEnter;
            templateClip += tab + SQ_Business_3 + datos.SQ_Business_3 + enter;
            templateClip += tab + "OUTAGE (Power Outage, Telephony, Email, Application, WAN/LAN, Server)" + singleEnter;
            templateClip += tab + SQ_Outage_1 + datos.SQ_Outage_1 + singleEnter;
            templateClip += tab + SQ_Outage_2 + datos.SQ_Outage_2 + singleEnter;
            templateClip += tab + SQ_Outage_3 + datos.SQ_Outage_3 + enter;
            templateClip += tab + "OTHER" + singleEnter;
            templateClip += tab + SQ_Other_1 + datos.SQ_Other_1 + singleEnter;
            templateClip += tab + SQ_Other_2 + datos.SQ_Other_2 + singleEnter;
            templateClip += tab + SQ_Other_3 + datos.SQ_Other_3 + enter;


            templateClip += ticketProvided + datos.Ticket_Otorgado + enter;
            templateClip += url + datos.url;

            if (datos.templateAdicional != "")
                templateClip += enter + datos.templateAdicional;

            if (datos.infoExtra != "")
                templateClip += enter + datos.infoExtra;

            grabarTemplate(templateClip, datos.Titulo, DateTime.Now.Hour + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Second);
            Clipboard.SetText(templateClip);
        }

        private settings set = new settings();

        public void grabarTemplate(String template, String titulo, String fecha)
        {
            StreamWriter SW;            
            SW = File.CreateText(set["local_path"].ToString() + set["templates_folder"].ToString()+ "[" + fecha + "] " + titulo + ".txt");
            SW.Write(template);
            SW.Close();
        }

        public void crearTextoTemplate(datosTemplate temp, string nombre)
        {
            StreamWriter SW;            
            SW = File.CreateText(@nombre);
            SW.WriteLine("[temp]");
            SW.WriteLine();
            SW.WriteLine("titulo = " + temp.Titulo);
            SW.WriteLine();
            SW.WriteLine("verificaste_SSNRFC = " + temp.Verificar_SSNRFC);
            SW.WriteLine();
            SW.WriteLine("esIMAC = " + temp.Es_IMAC);
            SW.WriteLine();
            SW.WriteLine("verificaste_Asset = " + temp.Verificar_Asset);
            SW.WriteLine();
            SW.WriteLine("idioma = " + temp.Idioma);
            SW.WriteLine();
            SW.WriteLine("keyword = " + temp.Keyword);
            SW.WriteLine();
            SW.WriteLine("detalles_problema = " + temp.Detalles_Ticket);
            SW.WriteLine();
            SW.WriteLine("acciones_realizadas = " + temp.Acciones_Realizadas);
            SW.WriteLine();
            SW.WriteLine("caja_despacho = " + temp.Caja_Asignacion);
            SW.WriteLine();
            SW.WriteLine("url = " + temp.url);
            SW.WriteLine();
            SW.WriteLine("severidad = " + temp.Severidad);
            SW.Close();
        }
    }
}
